!function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&i[i.length-1])&&(6===r[0]||2===r[0])){a=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]0)&&!(o=r.next()).done;)a.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return a}function i(e,t){for(var n=0,o=t.length,i=e.length;n0x7fffffffffff||t<-0x800000000000)&&(t&=0xffffffffffff);return t<0&&(t+=0x7ffffffffffff),t},S=function(){var e=window.navigator.appName,t=window.navigator.userAgent;return-1!==e.indexOf("Microsoft Internet Explorer")&&(-1!==t.indexOf("MSIE 8.0")||-1!==t.indexOf("MSIE 7.0")||-1!==t.indexOf("MSIE 9.0"))},w=function(){var e=window.navigator.appName,t=window.navigator.userAgent;return-1!==e.indexOf("Microsoft Internet Explorer")&&(-1!==t.indexOf("MSIE 8.0")||-1!==t.indexOf("MSIE 9.0"))},k=function(){var e=window.navigator.appName,t=window.navigator.userAgent;return-1!==e.indexOf("Microsoft Internet Explorer")&&-1!==t.indexOf("MSIE 7.0")},T="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function D(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function A(e,t){return e(t={exports:{}},t.exports),t.exports}var O=A(function(e,t){var n;n=function(){function e(){for(var e=0,t={};e-1&&(t=e.slice(0,e.indexOf("Build/")))});else if("ios"===e||"mac"===e||"windows"===e)if(this.isNewIpad())t="iPad";else{var n=navigator.userAgent.replace("Mozilla/5.0 (",""),o=n.indexOf(";");t=-1===o?"":n.slice(0,o)}}catch(e){return t.trim()}return t.trim()},e.prototype.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},e}(),G={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},B="5.2.1_tob";var N,U,L={cn:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},P="https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/visual-editor-rangers.js",z="https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/visual-ab-core.js",j="https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/heatmap-core";!function(e){e.Init="init",e.Config="config",e.Start="start",e.ReStart="re-start-sdk",e.Stop="stop-sdk",e.Ready="ready",e.CloudReady="cloud-ready",e.TokenComplete="token-complete",e.TokenStorage="token-storage",e.TokenFetch="token-fetch",e.TokenError="token-error",e.ConfigUuid="config-uuid",e.ConfigWebId="config-webid",e.ConfigDomain="config-domain",e.CustomWebId="custom-webid",e.AnonymousId="anonymous-id",e.TokenChange="token-change",e.TokenReset="token-reset",e.ConfigTransform="config-transform",e.EnvTransform="env-transform",e.SessionReset="session-reset",e.SessionResetTime="session-reset-time",e.Event="event",e.Events="events",e.EventNow="event-now",e.CleanEvents="clean-events",e.BeconEvent="becon-event",e.SubmitBefore="submit-before",e.SubmitScuess="submit-scuess",e.SubmitAfter="submit-after",e.SubmitError="submit-error",e.SubmitVerifyH="submit-verify-h5",e.BindToken="bind-token",e.BindTokenReady="bind-token-ready",e.CustomHeader="custom-request-header",e.Stay="stay",e.ResetStay="reset-stay",e.StayReady="stay-ready",e.SetStay="set-stay",e.RouteChange="route-change",e.RouteReady="route-ready",e.Ab="ab",e.AbVar="ab-var",e.AbAllVars="ab-all-vars",e.AbConfig="ab-config",e.AbExternalVersion="ab-external-version",e.AbVersionChangeOn="ab-version-change-on",e.AbVersionChangeOff="ab-version-change-off",e.AbOpenLayer="ab-open-layer",e.AbCloseLayer="ab-close-layer",e.AbReady="ab-ready",e.AbComplete="ab-complete",e.AbTimeout="ab-timeout",e.Profile="profile",e.ProfileSet="profile-set",e.ProfileSetOnce="profile-set-once",e.ProfileUnset="profile-unset",e.ProfileIncrement="profile-increment",e.ProfileAppend="profile-append",e.ProfileClear="profile-clear",e.TrackDuration="track-duration",e.TrackDurationStart="track-duration-start",e.TrackDurationEnd="track-duration-end",e.TrackDurationPause="track-duration-pause",e.TrackDurationResume="tracl-duration-resume",e.Autotrack="autotrack",e.AutotrackReady="autotrack-ready",e.SetExposureType="set-exposure-type",e.CepReady="cep-ready",e.TracerReady="tracer-ready",e.EncryptData="encrypt-data",e.LogSettingReady="logsetting-ready",e.SetResource="set-resource"}(N||(N={})),function(e){e.DEBUGGER_MESSAGE="debugger-message",e.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",e.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",e.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",e.DEBUGGER_MESSAGE_EVENT="debugger-message-event",e.DEVTOOL_WEB_READY="devtool-web-ready"}(U||(U={}));var V=N,K=void 0,q=(new Date).getTimezoneOffset(),H=parseInt("".concat(-q/60),10),J=60*q,F=7776e6,W=function(){function t(e,t){var n=this;this.is_first_time=!0,this.configPersist=!1,this.initConfig=t,this.collect=e;var o=new C(t.app_id,t.cookie_domain||"",t.cookie_expire||F).init();this.commonInfo=o;var i="__tea_cache_first_".concat(t.app_id);this.configKey="__tea_cache_config_".concat(t.app_id),this.sessionStorage=new x(!1,"session"),this.localStorage=new x(!1,"local"),t.configPersist&&(this.configPersist=!0,this.storage=1===t.configPersist?this.sessionStorage:this.localStorage);var r=this.localStorage.getItem(i);r&&1==r?this.is_first_time=!1:(this.is_first_time=!0,this.localStorage.setItem(i,"1")),this.envInfo={user:{user_unique_id:K,user_type:K,user_id:K,user_is_auth:K,user_is_login:K,device_id:K,web_id:K,ip_addr_id:K,user_unique_id_type:K,anonymous_id:K},header:{app_id:K,app_name:K,app_install_id:K,install_id:K,app_package:K,app_channel:K,app_version:K,ab_version:K,os_name:o.os_name,os_version:o.os_version,device_model:o.device_model,ab_client:K,traffic_type:K,client_ip:K,device_brand:K,os_api:K,access:K,language:o.language,region:K,app_language:K,app_region:K,creative_id:o.utm.creative_id,ad_id:o.utm.ad_id,campaign_id:o.utm.campaign_id,log_type:K,rnd:K,platform:o.platform,sdk_version:B,sdk_lib:"js",province:K,city:K,timezone:H,tz_offset:J,tz_name:K,sim_region:K,carrier:K,resolution:"".concat(o.screen_width,"x").concat(o.screen_height),browser:o.browser,browser_version:o.browser_version,referrer:o.referrer,referrer_host:o.referrer_host,width:o.screen_width,height:o.screen_height,screen_width:o.screen_width,screen_height:o.screen_height,utm_term:o.utm.utm_term,utm_content:o.utm.utm_content,utm_source:o.utm.utm_source,utm_medium:o.utm.utm_medium,utm_campaign:o.utm.utm_campaign,tracer_data:JSON.stringify(o.utm.tracer_data),custom:{},wechat_unionid:K,wechat_openid:K}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(o),this.initDomain(),this.initABData(),this.collect.on("route-change",function(e){n.changeReferInfo(e.config)})}return t.prototype.initDomain=function(){var e=this.initConfig.channel_domain;if(e)this.domain=e;else{var t=this.initConfig.channel;this.domain=d(G[t])}},t.prototype.setDomain=function(e){this.domain=e},t.prototype.getDomain=function(){return this.domain},t.prototype.getCommonInfo=function(e){return e?this.commonInfo[e]||"":this.commonInfo},t.prototype.initABData=function(){var e="__tea_sdk_ab_version_".concat(this.initConfig.app_id),t=null;if(this.initConfig.ab_cross){var n=this.localStorage.getCookie(e,this.initConfig.ab_cookie_domain);t=n?JSON.parse(n):null}else t=this.localStorage.getItem(e);this.setAbCache(t)},t.prototype.setAbCache=function(e){this.ab_cache=e},t.prototype.getAbCache=function(){return this.ab_cache},t.prototype.clearAbCache=function(){this.ab_cache={},this.ab_version=""},t.prototype.setAbVersion=function(e){this.ab_version=e},t.prototype.getAbVersion=function(){return this.ab_version},t.prototype.getUrl=function(e){var t="";switch(e){case"event":t="/list";break;case"webid":t="/webid";break;case"tobid":t="/tobid";break;case"profile":t="/profile/list";break;case"img":t="/gif";break;case"bind":t="/service/2/id_bind"}var n="";return this.initConfig.caller&&(n="?sdk_version=".concat(B,"&sdk_name=web&app_id=").concat(this.initConfig.app_id,"&caller=").concat(this.initConfig.caller)),this.initConfig.report_url?"".concat(this.initConfig.report_url).concat(n):"".concat(this.getDomain()).concat(t).concat(n)},t.prototype.setCustom=function(e){if(e&&e.latest_data&&e.latest_data.isLast)for(var t in delete e.latest_data.isLast,this.isLast=!0,e.latest_data){this.envInfo.header.custom[t]=e.latest_data[t];var n={};n["".concat(t)]=e.latest_data[t],this.set(n)}},t.prototype.changeReferInfo=function(e){var t=e;this.set({referrer:t.referrer});var n="";try{n=new URL(t.referrer).host}catch(e){}this.set({referrer_host:n||this.envInfo.header.referrer_host})},t.prototype.set=function(t){var n=this;Object.keys(t).forEach(function(o){if(void 0!==t[o]&&null!==t[o]||n.delete(o),"traffic_type"===o&&n.isLast&&(n.envInfo.header.custom.$latest_traffic_source_type=t[o]),"evtParams"===o)n.evtParams=e(e({},n.evtParams||{}),t.evtParams||{});else if("_staging_flag"===o)n.evtParams=e(e({},n.evtParams||{}),{_staging_flag:t._staging_flag});else if("reportErrorCallback"===o&&"function"==typeof t[o])n.reportErrorCallback=t[o];else{var i="",r="";if(o.indexOf(".")>-1){var a=o.split(".");i=a[0],r=a[1]}i?"user"===i||"header"===i?n.envInfo[i][r]=t[o]:(n.envInfo.header.custom[r]=t[o],n.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 添加了Custom",level:"info",time:Date.now(),infoType:"sdk",secType:"HEADER",common:"custom"})):Object.hasOwnProperty.call(n.envInfo.user,o)?(["user_type","ip_addr_id"].indexOf(o)>-1?n.envInfo.user[o]=t[o]?Number(t[o]):t[o]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(o)>-1?n.envInfo.user[o]=t[o]?String(t[o]):t[o]:["user_is_auth","user_is_login"].indexOf(o)>-1?n.envInfo.user[o]=Boolean(t[o]):"device_id"===o&&(n.envInfo.user[o]=t[o]),n.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 修改了公共参数",level:"info",time:Date.now(),infoType:"sdk",secType:"USER",common:o})):Object.hasOwnProperty.call(n.envInfo.header,o)?(n.envInfo.header[o]=t[o],n.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 修改了公共参数",level:"info",time:Date.now(),infoType:"sdk",secType:"HEADER",common:o})):(n.envInfo.header.custom[o]=t[o],n.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 添加了Custom",level:"info",time:Date.now(),infoType:"sdk",secType:"HEADER",common:"custom"}))}})},t.prototype.getSettingData=function(e){if(this.logSettingConfig&&!u(this.logSettingConfig[e]))return this.logSettingConfig[e]},t.prototype.setSettingData=function(e){this.logSettingConfig=e},t.prototype.get=function(e){try{return e?"evtParams"===e?this.evtParams:"reportErrorCallback"===e?this[e]:Object.hasOwnProperty.call(this.envInfo.user,e)?this.envInfo.user[e]:Object.hasOwnProperty.call(this.envInfo.header,e)?this.envInfo.header[e]:JSON.parse(JSON.stringify(this.envInfo[e])):JSON.parse(JSON.stringify(this.envInfo))}catch(e){console.log("get config stringify error "),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},t.prototype.setStore=function(e){try{if(!this.configPersist)return;var t=this.storage.getItem(this.configKey)||{};if(t&&Object.keys(e).length){var n=Object.assign(e,t);this.storage.setItem(this.configKey,n)}}catch(e){console.log("setStore error"),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message})}},t.prototype.getStore=function(){try{if(!this.configPersist)return null;var e=this.storage.getItem(this.configKey)||{};return e&&Object.keys(e).length?e:null}catch(e){return this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),null}},t.prototype.delete=function(e){try{if(!this.configPersist)return;var t=this.storage.getItem(this.configKey)||{};t&&Object.hasOwnProperty.call(t,e)&&(delete t[e],this.storage.setItem(this.configKey,t))}catch(e){this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),console.log("delete error")}},t}(),X=function(){function e(e,t){this.isLog=t||!1,this.name=e||""}return e.prototype.info=function(e){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: ".concat(this.name,"]")+" "+e)},e.prototype.warn=function(e){this.isLog&&console.warn("%c %s","color: yellow; background-color: black;","[instance: ".concat(this.name,"]")+" "+e)},e.prototype.error=function(e){this.isLog&&console.error("[instance: ".concat(this.name,"]")+" "+e)},e.prototype.throw=function(e){throw this.error(this.name),new Error(e)},e}(),$=function(){function e(e,t){this.native=e.enable_native||e["evitaN".split("").reverse().join("")],this.os=t.get("os_name")}var t=e.prototype;return t.bridgeInject=function(){try{return!!this.native&&(AppLogBridge?(console.log("AppLogBridge is injected"),AppLogBridge.osName?this.os=AppLogBridge.osName():this.os=this.os,!0):(console.log("AppLogBridge is not inject"),!1))}catch(e){return console.log("AppLogBridge is not inject"),!1}},t.bridgeReady=function(){var e=this;return new Promise(function(t,n){try{e.bridgeInject()?AppLogBridge.hasStarted(function(e){console.log("AppLogBridge is started? : "+e),e?t(!0):n(!1)}):n(!1)}catch(e){console.log("AppLogBridge, error:"+JSON.stringify(e.stack)),n(!1)}})},t.setNativeAppId=function(e){try{AppLogBridge.setNativeAppId(JSON.stringify(e)),console.log("change bridge appid, event report with appid: "+e)}catch(e){console.error("setNativeAppId error")}},t.setConfig=function(e){var t=this;try{Object.keys(e).forEach(function(n){"user_unique_id"===n?t.setUserUniqueId(e[n]):e[n]?t.addHeaderInfo(n,e[n]):t.removeHeaderInfo(n)})}catch(e){console.error("setConfig error")}},t.setUserUniqueId=function(e){try{AppLogBridge.setUserUniqueId(e)}catch(e){console.error("setUserUniqueId error")}},t.addHeaderInfo=function(e,t){try{AppLogBridge.addHeaderInfo(e,t)}catch(e){console.error("addHeaderInfo error")}},t.setHeaderInfo=function(e){try{AppLogBridge.setHeaderInfo(JSON.stringify(e))}catch(e){console.error("setHeaderInfo error")}},t.removeHeaderInfo=function(e){try{AppLogBridge.removeHeaderInfo(e)}catch(e){console.error("removeHeaderInfo error")}},t.reportPv=function(e){this.onEventV3("predefine_pageview",e)},t.onEventV3=function(e,t){try{AppLogBridge.onEventV3(e,t)}catch(e){console.error("onEventV3 error")}},t.profileSet=function(e){try{AppLogBridge.profileSet(e)}catch(e){console.error("profileSet error")}},t.profileSetOnce=function(e){try{AppLogBridge.profileSetOnce(e)}catch(e){console.error("profileSetOnce error")}},t.profileIncrement=function(e){try{AppLogBridge.profileIncrement(e)}catch(e){console.error("profileIncrement error")}},t.profileUnset=function(e){try{AppLogBridge.profileUnset(e)}catch(e){console.error("profileUnset error")}},t.profileAppend=function(e){try{AppLogBridge.profileAppend(e)}catch(e){console.error("profileAppend error")}},t.setExternalAbVersion=function(e){try{AppLogBridge.setExternalAbVersion(e)}catch(e){console.error("setExternalAbVersion error")}},t.getVar=function(e,t,n){try{"harmonyos"===this.os?n(AppLogBridge.getABTestConfigValueForKey(e,t)):"android"===this.os?n(AppLogBridge.getABTestConfigValueForKey(e,t)):AppLogBridge.getABTestConfigValueForKey(e,t,function(e){n(e)})}catch(e){console.error("getVar error"),n(t)}},t.getAllVars=function(e){try{"harmonyos"===this.os?e(AppLogBridge.getAllAbTestConfigs()):"android"===this.os?e(AppLogBridge.getAllAbTestConfigs()):AppLogBridge.getAllAbTestConfigs(function(t){e(t)})}catch(t){console.error("getAllVars error"),e(null)}},t.getAbSdkVersion=function(e){try{"harmonyos"===this.os?e(AppLogBridge.getAbSdkVersion()):"android"===this.os?e(AppLogBridge.getAbSdkVersion()):AppLogBridge.getAbSdkVersion(function(t){e(t)})}catch(t){console.error("getAbSdkVersion error"),e("")}},e}(),Q={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ON:500,RESPONSE:5001,TIMEOUT:5005};function Y(e,t,n,o,i,r,a,s,c,l){try{var u;if(window.XDomainRequest&&w()){u=new XDomainRequest;var h=s||"post";u.open(h,e),n&&(u.timeout=n,u.ontimeout=function(){r&&r(t,Q.TIMEOUT)}),u.onerror=function(){u.abort(),r&&r(t,Q.XHR_ON)},u.onload=function(){if(i){var e=null;if(u.responseText){try{e=JSON.parse(u.responseText)}catch(t){e={}}i(e,t)}}},setTimeout(function(){u.send(JSON.stringify(t))},0)}else if(window.ActiveXObject&&k()){u=new ActiveXObject("Micrsorf.XMLHTTP");h=s||"POST";u.open(h,e),n&&(u.timeout=n,u.ontimeout=function(){r&&r(t,Q.TIMEOUT)}),u.onerror=function(){u.abort(),r&&r(t,Q.XHR_ON)},u.onload=function(){if(i){var e=null;if(u.responseText){try{e=JSON.parse(u.responseText)}catch(t){e={}}i(e,t)}}},setTimeout(function(){u.send(JSON.stringify(t))},0)}else if(window.XMLHttpRequest){u=new XMLHttpRequest;h=s||"POST";u.open(h,e,!0),u.setRequestHeader("Content-Type","application/json; charset=utf-8"),a&&u.setRequestHeader("X-MCS-AppKey","".concat(a)),o&&(u.withCredentials=!0),n&&(u.timeout=n,u.ontimeout=function(){r&&r(t,Q.TIMEOUT)}),u.onreadystatechange=function(){if(4===u.readyState&&200===u.status&&i){var e=null;if(u.responseText){try{e=JSON.parse(u.responseText)}catch(t){e={}}i(e,t)}}},u.onerror=function(){u.abort(),r&&r(t,Q.XHR_ON)},u.send(JSON.stringify(t))}}catch(e){console.log(e.message)}}var Z=4e3,ee=4002,te=function(e,t,n,o){try{t.forEach(function(i){var r=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&void 0!==e[n]&&(t+="&".concat(n,"=").concat(encodeURIComponent(JSON.stringify(e[n]))));return t="&"===t.slice(0,1)?t.slice(1):t}(i),a=new Image(1,1);a.onload=function(){a=null,n&&n()},a.onerror=function(){a=null,o&&o(e,t,Z)},a.src="".concat(e,"?").concat(r)})}catch(n){o&&o(e,t,ee,n.message)}},ne=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},oe=function(){function e(){}return e.prototype.apply=function(e,t){var n=this;this.collect=e,this.storage=new x(!1,"session"),this.sessionKey="__tea_session_id_".concat(t.app_id),this.expireTime=t.expireTime||18e5,this.disableSession=t.disable_session,this.disableSession||(this.setSessionId(),this.collect.on(V.SessionReset,function(){n.resetSessionId()}),this.collect.on(V.SessionResetTime,function(){n.updateSessionIdTime()}))},e.prototype.updateSessionIdTime=function(){var e=this.storage.getItem(this.sessionKey);if(e&&e.sessionId){var t=e.timestamp;Date.now()-t>this.expireTime?e={sessionId:ne(),timestamp:Date.now()}:e.timestamp=Date.now(),this.storage.setItem(this.sessionKey,e),this.resetExpTime()}},e.prototype.setSessionId=function(){var e=this,t=this.storage.getItem(this.sessionKey);t&&t.sessionId?t.timestamp=Date.now():t={sessionId:ne(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,t),this.sessionExp=setInterval(function(){e.checkEXp()},this.expireTime)},e.prototype.getSessionId=function(){var e=this.storage.getItem(this.sessionKey);return this.disableSession?"":e&&e.sessionId?e.sessionId:""},e.prototype.resetExpTime=function(){var e=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){e.checkEXp()},this.expireTime))},e.prototype.resetSessionId=function(){var e={sessionId:ne(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,e)},e.prototype.checkEXp=function(){var e=this.storage.getItem(this.sessionKey);e&&e.sessionId&&(Date.now()-e.timestamp+30>=this.expireTime&&(e={sessionId:ne(),timestamp:Date.now()},this.storage.setItem(this.sessionKey,e)))},e}(),ie=function(){function t(e,t){var n=this;this.MAX_LEVEL=3,this.metaResource={},this.eventCache=[],t.enable_track_id&&(this.MAX_LEVEL=t.track_level||3,e.on(V.SetResource,function(e){n.metaResource=e}))}return t.prototype.handleMetaResource=function(t){var n=this;return Object.keys(this.metaResource).length?(t.forEach(function(t){var r=t.event,a=t.local_time_ms,s=t.params,c=e({},JSON.parse(s));try{for(var l in c)if(n.metaResource.hasOwnProperty(l)){var u=c[l],h=n.metaResource[l];if(h.length&&h.includes(u)){var f=ne();c.ubt_source_id=f,n.eventCache.length&&(c.ubt_source=i([],o(n.eventCache)).reverse()),n.eventCache.length>=n.MAX_LEVEL&&n.eventCache.shift(),n.eventCache.push({event:r,params:e(e({},JSON.parse(s)),{ubt_source_id:f}),local_time_ms:a})}break}}finally{t.params=JSON.stringify(c)}}),t):t},t}(),re=function(){function t(){this.eventLimit=50,this.eventCache=[],this.beconEventCache=[]}return t.prototype.apply=function(e,t){var n=this;this.collect=e,this.config=t,this.configManager=e.configManager,this.cacheStorgae=new x(!0),this.localStorage=new x(!1),this.trackId=new ie(e,t),this.maxReport=t.max_report||20,this.reportTime=t.reportTime||30,this.timeout=t.timeout||1e5,this.reportUrl=this.configManager.getUrl("event"),this.eventKey="__tea_cache_events_".concat(this.configManager.get("app_id")),this.beconKey="__tea_cache_events_becon_".concat(this.configManager.get("app_id")),this.abKey="__tea_sdk_ab_version_".concat(this.configManager.get("app_id")),this.refer_key="__tea_cache_refer_".concat(this.configManager.get("app_id")),this.collect.on(V.Ready,function(){n.reportAll(!1)}),this.collect.on(V.ConfigDomain,function(){n.reportUrl=n.configManager.getUrl("event")}),this.collect.on(V.Event,function(e){n.event(e)}),this.collect.on(V.BeconEvent,function(e){n.beconEvent(e)}),this.collect.on(V.CleanEvents,function(){n.reportAll(!1)}),this.collect.on(V.BindTokenReady,function(){n.reportAll(!1)}),this.linster()},t.prototype.linster=function(){var e=this;f(window,"unload",function(){e.reportAll(!0)},!1),g(function(){e.reportAll(!0)}),f(document,"visibilitychange",function(){"hidden"===document.visibilityState&&e.reportAll(!0)},!1)},t.prototype.reportAll=function(e){this.report(e),this.reportBecon()},t.prototype.event=function(e){var t=this;try{var n=this.cacheStorgae.getItem(this.eventKey)||[],r=i(i([],o(e)),o(n));if(this.cacheStorgae.setItem(this.eventKey,r),this.reportTimeout&&clearTimeout(this.reportTimeout),r.length>=this.maxReport)this.report(!1);else{var a=this.reportTime;this.reportTimeout=setTimeout(function(){t.report(!1),t.reportTimeout=null},a)}}catch(e){this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 发生了异常",level:"error",time:Date.now(),data:e.message,infoType:"sdk"})}},t.prototype.beconEvent=function(e){if(!this.collect.destroyInstance&&!this.collect.sdkStop){var t=this.cacheStorgae.getItem(this.beconKey)||[],n=i(i([],o(e)),o(t));this.cacheStorgae.setItem(this.beconKey,n),this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(n)),!0))}},t.prototype.reportBecon=function(){if(!this.collect.destroyInstance&&!this.collect.sdkStop&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var e=this.cacheStorgae.getItem(this.beconKey)||[];e&&e.length&&(this.cacheStorgae.removeItem(this.beconKey),this.send(this.split(this.merge(e)),!0))}},t.prototype.report=function(e){if(!this.collect.destroyInstance&&!this.collect.sdkStop&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var t=this.cacheStorgae.getItem(this.eventKey)||[];t.length&&(this.cacheStorgae.removeItem(this.eventKey),this.sliceEvent(t,e))}},t.prototype.sliceEvent=function(e,t){if(e.length>this.eventLimit)for(var n=0;n>t/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}().replace(/-/g,"").slice(0,19)},se=function(){function t(){this.cacheToken={},this.enableCookie=!1,this.enableTTwebid=!1,this.enableCustomWebid=!1,this.enableAnonymousid=!1}return t.prototype.apply=function(e,t){var n=this;this.collect=e,this.config=t,this.configManager=this.collect.configManager,this.storage=new x(!1),this.tokenKey="__tea_cache_tokens_".concat(t.app_id),this.enableAnonymousid=t.enable_anonymousid,this.enableTTwebid=t.enable_ttwebid,this.enableCustomWebid=t.enable_custom_webid,this.timeout=t.timeout||3e5,this.collect.on(V.AnonymousId,function(e){n.setAnonymousId(e)}),this.collect.on(V.ConfigUuid,function(e){n.setUuid(e)}),this.collect.on(V.ConfigWebId,function(e){n.setWebId(e)}),this.collect.on(V.BindToken,function(e){n.fetchBind(e)}),this.enableCookie=t.cross_subdomain,this.expiresTime=t.cookie_expire||6048e5,this.cookieDomain=t.cookie_domain||"",this.checkStorage()},t.prototype.checkStorage=function(){var e=this;if(this.enableCookie){var t=this.storage.getCookie(this.tokenKey,this.cookieDomain);this.cacheToken=t&&"string"==typeof t?JSON.parse(t):{}}else this.cacheToken=this.storage.getItem(this.tokenKey)||{};this.tokenType=this.cacheToken&&this.cacheToken._type_?this.cacheToken._type_:"default","custom"!==this.tokenType||this.enableCustomWebid||this.enableAnonymousid?this.enableAnonymousid?this.completeAnonymous(this.cacheToken):this.enableCustomWebid?this.collect.on(V.CustomWebId,function(){e.tokenReady=!0,e.collect.emit(V.TokenComplete)}):this.checkEnv()||(this.enableTTwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},t.prototype.check=function(){if(this.cacheToken&&this.cacheToken.web_id)this.complete(this.cacheToken);else if(this.config.disable_webid){var e=this.getLocalId();this.complete({web_id:e,user_unique_id:this.configManager.get("user_unique_id")||e})}else this.remoteWebid()},t.prototype.checkEnv=function(){var e=window.navigator.userAgent;if(-1!==e.indexOf("miniProgram")||-1!==e.indexOf("MiniProgram")){var t=b(window.location.href);return!(!t||!t.Web_ID)&&(this.complete({web_id:"".concat(t.Web_ID),user_unique_id:this.configManager.get("user_unique_id")||"".concat(t.Web_ID)}),!0)}return!1},t.prototype.remoteWebid=function(){var e=this,t=this.configManager.getUrl("webid"),n={app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer,user_unique_id:""};this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 发起WEBID请求",logType:"fetch",level:"info",time:Date.now(),data:n});var o=this.collect.cryptoData(n);this.collect.requestManager.useRequest({url:t,data:o,success:function(t){var n;if(t&&0===t.e)n=t.web_id,e.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"WEBID请求成功",logType:"fetch",level:"info",time:Date.now(),data:t});else{var o=e.getLocalId();n=o,e.collect.configManager.set({localWebId:o}),e.collect.emit(V.TokenError),e.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"WEBID请求返回值异常",logType:"fetch",level:"warn",time:Date.now(),data:t}),e.collect.logger.warn("appid: ".concat(e.config.app_id," get webid error, use local webid~"))}e.complete({web_id:e.configManager.get("web_id")||n,user_unique_id:e.configManager.get("user_unique_id")||n})},fail:function(){var t=e.getLocalId();e.complete({web_id:e.configManager.get("web_id")||t,user_unique_id:e.configManager.get("user_unique_id")||t}),e.collect.configManager.set({localWebId:t}),e.collect.emit(V.TokenError),e.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"WEBID请求网络异常",logType:"fetch",level:"error",time:Date.now(),data:null}),e.collect.logger.warn("appid: ".concat(e.config.app_id,", get webid error, use local webid~"))},timeout:this.timeout,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},t.prototype.getLocalId=function(){for(var e=ae(),t=0;0===e.indexOf("0")||0===e.indexOf("9");){if(t>=10){e=e.replace(/^(0|9)/,"");break}e=ae(),t++}return e},t.prototype.complete=function(e){var t=e.web_id,n=e.user_unique_id;if(!t&&!n)return this.collect.emit(V.TokenError),void console.warn("token error");e.timestamp=Date.now(),0===t.indexOf("9")&&t.length>18?this.remoteWebid():(this.collect.configManager.set({web_id:t,user_unique_id:n}),this.setStorage(e),this.tokenReady=!0,this.collect.emit(V.TokenComplete))},t.prototype.completeAnonymous=function(e){var t=e.anonymous_id||ne(),n=e.user_unique_id||this.configManager.get("user_unique_id");this.collect.configManager.set({anonymous_id:t,user_unique_id:n||t}),e.anonymous_id=t,e.user_unique_id=n||t,this.setStorage(e),this.tokenReady=!0,this.collect.emit(V.TokenComplete)},t.prototype.completeTtWid=function(e){var t=e.user_unique_id||"",n=this.configManager.get("user_unique_id");this.configManager.set({user_unique_id:n||t}),this.setStorage(e),this.tokenReady=!0,this.collect.emit(V.TokenComplete)},t.prototype.setUuid=function(e){if(e&&-1===["null","undefined","Null","None"].indexOf(e)){var t=String(e),n=this.configManager.get("user_unique_id"),o=this.cacheToken&&this.cacheToken.user_unique_id;if(t===n&&t===o)return;this.configManager.set({user_unique_id:t}),this.cacheToken?this.cacheToken.user_unique_id=t:(this.cacheToken={},this.cacheToken.user_unique_id=t),this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(V.TokenChange,{type:"uuid",id:e}),this.collect.emit(V.ProfileClear),this.collect.emit(V.SessionReset)}else this.clearUuid()},t.prototype.clearUuid=function(){if(!this.config.enable_ttwebid){var e=this.enableAnonymousid?this.configManager.get("anonymous_id"):this.configManager.get("web_id");this.configManager.get("user_unique_id")!==e&&(this.configManager.set({user_unique_id:e}),this.cacheToken.user_unique_id=e,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(V.ProfileClear),this.collect.emit(V.TokenReset))}},t.prototype.setAnonymousId=function(e){if(e&&this.enableAnonymousid){var t=this.configManager.get("anonymous_id"),n=this.configManager.get("user_unique_id");t!==e&&(t!==n&&n||(this.configManager.set({user_unique_id:e}),this.cacheToken.user_unique_id=e,this.collect.emit(V.TokenChange,{type:"uuid",id:e})),this.configManager.set({anonymous_id:e}),this.cacheToken.anonymous_id=e,this.collect.emit(V.TokenChange,{type:"anonymous_id",id:e}),this.setStorage(this.cacheToken))}},t.prototype.setWebId=function(e){if(e&&!this.config.enable_ttwebid&&!this.enableAnonymousid){var t=this.configManager.get("web_id"),n=this.configManager.get("user_unique_id");n&&n!==t||(this.configManager.set({user_unique_id:e}),this.cacheToken.user_unique_id=e,this.collect.emit(V.TokenChange,{type:"uuid",id:e})),t!==e&&(this.configManager.set({web_id:e}),this.cacheToken.web_id=e,this.collect.emit(V.ProfileClear),this.collect.emit(V.TokenChange,{type:"webid",id:e})),this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)}},t.prototype.setStorage=function(e){e._type_=this.enableCustomWebid?"custom":"default",delete e["diss".split("").reverse().join("")],this.enableCookie||this.enableTTwebid?this.storage.setCookie(this.tokenKey,e,this.expiresTime,this.cookieDomain):this.storage.setItem(this.tokenKey,e),this.cacheToken=e},t.prototype.getReady=function(){return this.tokenReady},t.prototype.getTobId=function(e){var t=this,n={app_id:this.config.app_id,user_unique_id:this.configManager.get("user_unique_id"),user_unique_id_type:this.configManager.get("user_unique_id_type")};this.enableAnonymousid?n.anonymous_id=this.configManager.get("anonymous_id"):n.web_id=this.configManager.get("web_id");var o=this.collect.cryptoData(n);this.collect.requestManager.useRequest({url:this.configManager.getUrl("tobid"),data:o,success:function(n){n&&0===n.e?(e(n.tobid),t.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"GetToken请求成功",logType:"fetch",level:"info",time:Date.now(),data:n,infoType:"sdk"})):(e(""),t.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),data:n,infoType:"sdk"}))},fail:function(){e(""),t.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),infoType:"sdk"})},time:this.timeout,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},t.prototype.fetchBind=function(t){var n=this,o=t.params,i=t.callback,r=this.configManager.getUrl("bind"),a={header:{aid:this.configManager.get("app_id"),identities:e({},o)}};this.collect.requestManager.useRequest({url:r,data:a,success:function(e){i(e),n.collect.sdkStop=!1,n.collect.emit(V.BindTokenReady)},fail:function(e){i(e),n.collect.sdkStop=!1,n.collect.emit(V.BindTokenReady)},time:3e4,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},t}(),ce=function(){return!(!window.navigator||!window.navigator.sendBeacon)},le=function(){function e(e,t){var n=this;this.collector=e,this.config=t,this.requestType=t.request_type||"xhr",this.supportBeacon=ce(),this.errorCode={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ON:500,RESPONSE:5001,TIMEOUT:5005},this.customHeader=t.custom_request_header||{},this.collector.on("custom-request-header",function(e){n.setRequestHeader(e)})}return e.prototype.setRequestHeader=function(e){this.customHeader=Object.assign(this.customHeader,e)},e.prototype.useFetch=function(e){var t=e.url,n=e.data,o=e.method,i=e.success,r=e.fail,a={"Content-Type":"application/json; charset=utf-8"};if(Object.keys(this.customHeader).length)for(var s in this.customHeader)a[s]=this.customHeader[s];window.fetch?fetch(t,{method:o||"POST",headers:a,body:JSON.stringify(n)}).then(function(e){return e.json()}).then(function(e){i&&i(e)}).catch(function(e){r&&r(n,e)}):(this.requestType="xhr",console.log("your brwoser not support fetch, use xhr"),this.useRequest({url:t,data:n,method:o,success:i,fail:r}))},e.prototype.useBeacon=function(e){var t=e.url,n=e.data,o=e.success,i=e.fail;window.navigator.sendBeacon(t,JSON.stringify(n))?o&&o():i&&i(n,this.errorCode.BEACON_FALSE)},e.prototype.useRequest=function(e){var t=this,n=e.url,o=e.data,i=e.method,r=e.success,a=e.fail,s=e.timeout,c=e.useBeacon,l=e.withCredentials,u=e.app_key,h=e.forceXhr,f=(e.encryption,e.encryption_header,e.status);e.zip;if(c&&this.supportBeacon)this.useBeacon({url:n,data:o,method:i,success:r,fail:a});else if("fetch"!==this.requestType||h)try{var p=null;if(window.XDomainRequest&&w()){p=new XDomainRequest;var d=i||"post";p.open(d,n),s&&(p.timeout=s,p.ontimeout=function(){a&&a(o,t.errorCode.TIMEOUT)}),p.onerror=function(){p.abort(),a&&a(o,t.errorCode.XHR_ON)},p.onload=function(){if(r){var e=null;if(p.responseText){try{e=JSON.parse(p.responseText)}catch(t){e={}}r(e,o)}}},setTimeout(function(){p.send(JSON.stringify(o))},0)}else if(window.ActiveXObject&&k()){p=new ActiveXObject("Micrsorf.XMLHTTP");d=i||"POST";p.open(d,n),s&&(p.timeout=s,p.ontimeout=function(){a&&a(o,t.errorCode.TIMEOUT)}),p.onerror=function(){p.abort(),a&&a(o,t.errorCode.XHR_ON)},p.onload=function(){if(r){var e=null;if(p.responseText){try{e=JSON.parse(p.responseText)}catch(t){e={}}r(e,o)}}},setTimeout(function(){p.send(JSON.stringify(o))},0)}else if(window.XMLHttpRequest){p=new XMLHttpRequest;d=i||"POST";if(p.open(d,"".concat(n),!0),p.setRequestHeader("Content-Type","application/json; charset=utf-8"),u&&p.setRequestHeader("X-MCS-AppKey","".concat(u)),Object.keys(this.customHeader).length)for(var g in this.customHeader)p.setRequestHeader(g,this.customHeader[g]);l&&(p.withCredentials=!0),s&&(p.timeout=s,p.ontimeout=function(){a&&a(o,t.errorCode.TIMEOUT)}),p.onload=function(){if(r){var e=null;if(p.responseText){try{e=JSON.parse(p.responseText)}catch(t){e={}}r(e,o,f),t.collector.emit("http-ok",{data:o,status:f})}}},p.onerror=function(){a&&a(o,t.errorCode.XHR_ON),t.collector.emit("http-error",{data:o,status:f}),p.abort()},p.send(JSON.stringify(o))}}catch(e){this.collector.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK useRequest 发送请求发生了一些问题",level:"error",time:Date.now(),data:e.message,infoType:"sdk"})}else this.useFetch({url:n,data:o,method:i,success:r,fail:a})},e}(),ue=function(){function t(){}return t.prototype.apply=function(e,t){var n=this;if(!S()){this.collect=e,this.config=t,this.duration=6e4,this.reportUrl="".concat(e.configManager.getDomain(),"/profile/list");var o=e.Types,i=e.adapters.fetch;this.fetch=i,this.cache={},this.collect.on(o.ProfileSet,function(e){n.setProfile(e)}),this.collect.on(o.ProfileSetOnce,function(e){n.setOnceProfile(e)}),this.collect.on(o.ProfileUnset,function(e){n.unsetProfile(e)}),this.collect.on(o.ProfileIncrement,function(e){n.incrementProfile(e)}),this.collect.on(o.ProfileAppend,function(e){n.appendProfile(e)}),this.collect.on(o.ProfileClear,function(){n.cache={}}),this.ready(o.Profile)}},t.prototype.ready=function(e){var t=this;if(this.collect.set(e),this.collect.hook._hooksCache.hasOwnProperty(e)){var n=this.collect.hook._hooksCache[e];if(!Object.keys(n).length)return;var o=function(e){n[e].length&&n[e].forEach(function(n){t.collect.hook.emit(e,n)})};for(var i in n)o(i)}},t.prototype.report=function(e,t){void 0===t&&(t={});try{if(this.config.disable_track_event)return;if(this.collect.sdkStop)return;var n=[];n.push(this.collect.processEvent(e,t));var o=this.collect.eventManager.merge(n,!0),i=this.collect.cryptoData(o);this.collect.configManager.getUrl("profile");this.collect.requestManager.useRequest({url:this.reportUrl,data:i,timeout:1e5,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0}),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_EVENT,info:"profile 埋点上报成功",time:Date.now(),data:o,code:200,status:"success"})}catch(e){this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"profile report 发生了异常",level:"error",time:Date.now(),data:e.message,infoType:"sdk"})}},t.prototype.setProfile=function(t){var n=this.formatParams(t);n&&Object.keys(n).length&&(this.pushCache(n),this.report("__profile_set",e(e({},n),{profile:!0})))},t.prototype.setOnceProfile=function(t){var n=this.formatParams(t,!0);n&&Object.keys(n).length&&(this.pushCache(n),this.report("__profile_set_once",e(e({},n),{profile:!0})))},t.prototype.incrementProfile=function(t){t?this.report("__profile_increment",e(e({},t),{profile:!0})):console.warn("please check the params, must be object!!!")},t.prototype.unsetProfile=function(t){if(t){var n={};n[t]="1",this.report("__profile_unset",e(e({},n),{profile:!0}))}else console.warn("please check the key, must be string!!!")},t.prototype.appendProfile=function(t){if(t){var n={};for(var o in t)"string"==typeof t[o]||"Array"===Object.prototype.toString.call(t[o]).slice(8,-1)?n[o]=t[o]:console.warn("please check the value of param: ".concat(o,", must be string or array !!!"));Object.keys(n).length&&this.report("__profile_append",e(e({},n),{profile:!0}))}else console.warn("please check the params, must be object!!!")},t.prototype.pushCache=function(e){var t=this;Object.keys(e).forEach(function(n){t.cache[n]={val:t.clone(e[n]),timestamp:Date.now()}})},t.prototype.formatParams=function(e,t){var n=this;void 0===t&&(t=!1);try{if(!e||"[object Object]"!==Object.prototype.toString.call(e))return void console.warn("please check the params type, must be object !!!");var o={};for(var i in e)"string"==typeof e[i]||"number"==typeof e[i]||"Array"===Object.prototype.toString.call(e[i]).slice(8,-1)?o[i]=e[i]:console.warn("please check the value of params:".concat(i,", must be string,number,Array !!!"));var r=Object.keys(o);if(!r.length)return;var a=Date.now();return r.filter(function(o){var i=n.cache[o];return t?!i:!(i&&n.compare(i.val,e[o])&&a-i.timestamp';var i=document.createElement("div");i.innerHTML='
',document.getElementsByTagName("body")[0].appendChild(o),document.getElementsByTagName("body")[0].appendChild(i);var r=document.getElementById("debugger-applog-web");r&&r.addEventListener("click",function(){window&&window.postMessage({type:"devtool:web:open-draw"},location.origin)})},e}();var me=function(){function t(e){this.disableAutoPageView=!1,this.bridgeReport=!1,this.staging=!1,this.pluginInstances=[],this.sended=!1,this.started=!1,this.destroyInstance=!1,this.adapters={},this.sdkReady=!1,this.name=e,this.hook=new a(this),this.logger=new X(e),this.remotePlugin=new Map,this.Types=V,this.adapters.fetch=Y,this.adapters.storage=x}return t.usePlugin=function(e,n,o){if(n){for(var i=!1,r=0,a=t.plugins.length;rt[0]?1:0}),e._entries&&(e._entries={});for(var n=0;n1?i(o[1]):"")}})}(void 0!==T?T:"undefined"!=typeof window?window:"undefined"!=typeof self?self:T),function(e){if(function(){try{var t=new e.URL("b","http://a");return t.pathname="c d","http://a/c%20d"===t.href&&t.searchParams}catch(t){return!1}}()||function(){var t=e.URL,n=function t(n,o){"string"!=typeof n&&(n=String(n)),o&&"string"!=typeof o&&(o=String(o));var i,r=document;if(o&&(void 0===e.location||o!==e.location.href)){o=o.toLowerCase(),(i=(r=document.implementation.createHTMLDocument("")).createElement("base")).href=o,r.head.appendChild(i);try{if(0!==i.href.indexOf(o))throw new Error(i.href)}catch(t){throw new Error("URL unable to set base "+o+" due to "+t)}}var a=r.createElement("a");a.href=n,i&&(r.body.appendChild(a),a.href=a.href);var s=r.createElement("input");if(s.type="url",s.value=n,":"===a.protocol||!/:/.test(a.href)||!s.checkValidity()&&!o)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:a});var c=new e.URLSearchParams(this.search),l=!0,u=!0,h=this;["append","delete","set"].forEach(function(e){var t=c[e];c[e]=function(){t.apply(c,arguments),l&&(u=!1,h.search=c.toString(),u=!0)}}),Object.defineProperty(this,"searchParams",{value:c,enumerable:!0});var f=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==f&&(f=this.search,u&&(l=!1,this.searchParams._fromString(this.search),l=!0))}})},o=n.prototype;["hash","host","hostname","port","protocol"].forEach(function(e){!function(e){Object.defineProperty(o,e,{get:function(){return this._anchorElement[e]},set:function(t){this._anchorElement[e]=t},enumerable:!0})}(e)}),Object.defineProperty(o,"search",{get:function(){return this._anchorElement.search},set:function(e){this._anchorElement.search=e,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(o,{toString:{get:function(){var e=this;return function(){return e.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(e){this._anchorElement.href=e,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(e){this._anchorElement.pathname=e},enumerable:!0},origin:{get:function(){var e={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],t=this._anchorElement.port!=e&&""!==this._anchorElement.port;return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(t?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(e){},enumerable:!0},username:{get:function(){return""},set:function(e){},enumerable:!0}}),n.createObjectURL=function(e){return t.createObjectURL.apply(t,arguments)},n.revokeObjectURL=function(e){return t.revokeObjectURL.apply(t,arguments)},e.URL=n}(),void 0!==e.location&&!("origin"in e.location)){var t=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:t,enumerable:!0})}catch(n){setInterval(function(){e.location.origin=t()},100)}}}(void 0!==T?T:"undefined"!=typeof window?window:"undefined"!=typeof self?self:T);var _e={},be=[],Ee=function(e){e.length&&e.forEach(function(e){be.push(e)})};function Se(e,t,n,o){var i=e&&e.source||window.opener||window.parent,r=e&&e.origin||o||"*",a={type:t,payload:n};i.postMessage(JSON.stringify(a),r)}function we(e,t){_e[e]=_e[e]||[],_e[e].push(t)}function ke(e){if(be.some(function(e){return"*"===e})||be.some(function(t){return e.origin.indexOf(t)>-1})){var t=e.data;if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(e){t=void 0}if(!t)return;var n=t.type,o=t.payload;_e[n]&&_e[n].forEach(function(t){"function"==typeof t&&t(e,o)})}}function Te(e,t){var n={};if(Object.keys(e).length)for(var o in e){if("filter"===o||"autotrack"===o||"enable_stay_duration"===o)break;n[o]=e[o]}(window.opener||window.parent).postMessage({type:"tea:sdk:info",config:n,version:t},"*"),window.addEventListener("message",ke,!1)}var De="",Ae=!1;function Oe(e){var t=e.event,n=e.editorUrl;e.collectInstance,e.fromSession;Ae||(Ae=!0,v(n,function(){Se(t,"abEditorScriptloadSuccess")},function(){t&&Se(t,"abEditorScriptloadError"),Ae=!1}))}var Ie;!function(e){e[e.Var=0]="Var",e[e.All=1]="All"}(Ie||(Ie={}));var Re=function(){function t(){this.fetchStatus="no",this.refreshFetchStatus="complete",this.versions=[],this.extVersions=[],this.mulilinkVersions=[],this.enable_multilink=!1,this.enable_ab_visual=!1,this.editMode=!1,this.callbacks=[],this.data=null,this.changeListener=new Map,this.readyStatus=!1,this.exposureCache=[],this.auto_exposure=!1}return t.prototype.apply=function(e,t){var n=this;if(this.collect=e,this.config=t,this.config.enable_ab_test){var o=e.configManager.getSettingData("bav_ab_config");if(!l(o)||o){var i=t.enable_multilink,r=t.ab_channel_domain,a=t.enable_ab_visual,s=t.ab_cross,c=t.ab_cookie_domain,u=t.disable_ab_reset,h=t.auto_exposure_expriment,f=r||d(L[t.channel||"cn"]),p=e.adapters,g=p.storage,v=p.fetch;this.cacheStorgae=new g(!1),this.fetch=v,this.enable_multilink=i,this.enable_ab_visual=a,this.abKey="__tea_sdk_ab_version_".concat(t.app_id),this.ab_cross=s,this.ab_cookie_domain=c||"",this.fetchUrl="".concat(f).concat("/service/2/abtest_config/"),this.reportUrl="".concat(e.configManager.getUrl("event")),this.exposureLimit=t.exposure_limit||5,this.ab_batch_time=t.ab_batch_time||50,this.overlay_opacity=t.overlay_opacity||0,this.auto_exposure=h;var m=this.collect.Types;this.types=m;var y=e.configManager.getSettingData("bav_ab_refresh");this.collect.on(m.TokenChange,function(e){u||l(o)&&!y||"uuid"===e.type&&n.readyStatus&&(n.clearCache(),n.fetchAB())}),this.collect.on(m.TokenReset,function(){u||l(o)&&!y||n.readyStatus&&(n.clearCache(),n.fetchAB())}),this.collect.on(m.AbVar,function(e){var t=e.name,o=e.defaultValue,i=e.callback;n.getVar(t,o,i)}),this.collect.on(m.AbAllVars,function(e){n.getAllVars(e)}),this.collect.on(m.AbConfig,function(e){var t=e.params,o=e.callback;n.getABconfig(t,o)}),this.collect.on(m.AbExternalVersion,function(e){n.setExternalAbVersion(e)}),this.collect.on(m.AbOpenLayer,function(){n.openOverlayer()}),this.collect.on(m.AbCloseLayer,function(){n.closeOverlayer()}),this.collect.on(m.AbVersionChangeOn,function(e){n.changeListener.set(e,e)}),this.collect.on(m.AbVersionChangeOff,function(e){n.changeListener.get(e)&&n.changeListener.delete(e)}),this.loadMode(),(this.enable_ab_visual||this.enable_multilink)&&this.openOverlayer(this.config.multilink_timeout_ms||500),this.checkLocal(),this.ready("ab"),this.readyStatus||(this.fetchAB(),this.readyStatus=!0),this.collect.emit(m.AbReady)}}},t.prototype.ready=function(e){var t=this;if(this.collect.set(e),this.collect.hook._hooksCache.hasOwnProperty(e)){var n=this.collect.hook._hooksCache[e];if(!Object.keys(n).length)return;var o=function(e){n[e].length&&n[e].forEach(function(n){t.collect.hook.emit(e,n)})};for(var i in n)o(i)}},t.prototype.loadMode=function(){var e,t,n=function(){try{var e=JSON.parse(atob(window.name));return e||void 0}catch(e){return}}(),o="";if(n){var i=n.scenario,r=n.href;i?(this.editMode=!0,o=i):!r||-1===r.indexOf("datatester")&&-1===r.indexOf("visual-editor")||(this.editMode=!0,o="visual-editor")}this.enable_ab_visual&&(function(e,t){window.TEAVisualEditor=window.TEAVisualEditor||{},Ee(["*"]);var n,o="";Te(t,B);var i="";try{var r=window.performance.getEntriesByType("resource");if(r&&r.length&&(r.forEach(function(e){"script"===e.initiatorType&&e.name&&-1!==e.name.indexOf("collect")&&(i=e.name)}),i||document.currentScript&&(i=document.currentScript.src),i&&(n=i.split("/"))&&n.length)){o="https:/";for(var a=2;a0&&this.changeListener.forEach(function(t){"function"==typeof t&&t(e)})},t.prototype.configVersions=function(e){this.collect.configManager.setAbVersion(e)},t.prototype.getVar=function(e,t,n){if(!e)throw new Error("variable must not be empty");if(void 0===t)throw new Error("variable no default value");if("function"!=typeof n)throw new Error("callback must be a function");var o={name:e,defaultValue:t,callback:n,type:Ie.Var};this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用GetVar",level:"info",time:Date.now(),data:e,infoType:"cus"}),"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealVar(o,e):this.callbacks.push(o)},t.prototype.getRealVar=function(e,t){var n=e.name,o=e.defaultValue,i=e.callback,r=this.data;if(r){if(s(r[n])){var a=r[n].vid;return"$ab_url"===t?this.mulilinkVersions.includes(a)||this.mulilinkVersions.push(a):this.versions.includes(a)||this.versions.push(a),this.updateVersions(),this.fechEvent(a,t,o),i(r[n].val),void this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK执行GetVar,并曝光了实验".concat(n),level:"info",time:Date.now(),data:r[n],infoType:"sdk"})}i(o),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK执行GerVar默认回调",level:"info",time:Date.now(),data:this.data,infoType:"sdk"})}else i(o)},t.prototype.getAllVars=function(e){if("function"!=typeof e)throw new Error("callback must be a function");var t={callback:e,type:Ie.All};this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用GetAllVars",level:"info",time:Date.now(),infoType:"cus"}),"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealAllVars(t):this.callbacks.push(t)},t.prototype.getRealAllVars=function(e){(0,e.callback)(this.data?JSON.parse(JSON.stringify(this.data)):{}),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 执行GetAllVars",level:"info",time:Date.now(),data:this.data,infoType:"sdk"})},t.prototype.exposureAll=function(e){try{if(Object.keys(e).length)for(var t in e){if("$ab_url"===t||"$ab_modification"===t)break;this.getRealVar({name:t,defaultValue:e[t].val,callback:function(){},type:Ie.Var},t)}}catch(e){console.warn("exposure all expriment err",JSON.stringify(e.message))}},t.prototype.fechEvent=function(e,t,n){try{if(this.config.disable_track_event)return;if(this.collect.sdkStop)return;if(!e)return;var o=this.collect.configManager.get(),i=o.header,r=o.user,a=this.getABCache();if(a&&a.uuid&&a.uuid!==r.user_unique_id)return;var s={event:"abtest_exposure",ab_sdk_version:"".concat(e),params:JSON.stringify({app_id:this.config.appId,ab_url:"$ab_url"===t?n:window.location.href}),local_time_ms:Date.now()};i.custom=JSON.stringify(i.custom);var c={events:[s],user:r,header:i};this.reportExposure(c,t)}catch(e){this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 发生了异常",level:"error",time:Date.now(),data:e.message,infoType:"sdk"})}},t.prototype.reportExposure=function(e,t){this.exposureCache.push(e),this.report(t)},t.prototype.report=function(e){var t=this;try{var n=this.collect.cryptoData(this.exposureCache);if(S())return void te(this.collect.configManager.getUrl("img"),n);this.collect.requestManager.useRequest({url:this.reportUrl,data:n,timeout:1e5,useBeacon:"$ab_url"===e,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0}),this.exposureCache.forEach(function(e){t.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_EVENT,info:"曝光埋点上报成功",time:Date.now(),data:[e],code:200,status:"success",infoType:"sdk"})}),this.exposureCache=[]}catch(e){console.log("ab report err",e)}},t.prototype.setExternalAbVersion=function(e){this.extVersions=[e],this.updateVersions()},t.prototype.getABconfig=function(e,t){var n=Object.keys(e);n&&n.length&&this.collect.configManager.set(e),this.fetchAB(t)},t.prototype.get=function(e){if(this.ab_cross){var t=this.cacheStorgae.getCookie(e,this.ab_cookie_domain);return t?JSON.parse(t):null}return this.cacheStorgae.getItem(e)},t.prototype.set=function(e,t){this.ab_cross?this.cacheStorgae.setCookie(e,t,2592e6,this.ab_cookie_domain):this.cacheStorgae.setItem(e,t),this.collect.configManager.setAbCache(t)},t.prototype.remove=function(){this.ab_cross?this.cacheStorgae.removeCookie(this.abKey,this.ab_cookie_domain):this.cacheStorgae.removeItem(this.abKey)},t.prototype.getABCache=function(e){var t={ab_version:[],ab_ext_version:[],ab_version_multilink:[],data:null,timestamp:+new Date,uuid:""};return t=this.get(this.abKey)||t,e?t[e]:t},t.prototype.updateABCache=function(){var e=this.getABCache();e.ab_version_multilink=this.mulilinkVersions,e.ab_ext_version=this.extVersions,e.ab_version=this.versions,e.timestamp=Date.now(),this.set(this.abKey,e)},t.prototype.setAbCache=function(e){var t=this.getABCache();t.data=this.data,t.uuid=e,t.timestamp=Date.now(),this.set(this.abKey,t)},t.prototype.clearCache=function(){this.refreshFetchStatus="ing",this.data={},this.extVersions=[],this.mulilinkVersions=[],this.versions=[],this.collect.configManager.clearAbCache()},t.prototype.openOverlayer=function(e){var t=this;if(function(e){if(!document.getElementById(ye)){var t="body { opacity: ".concat(e," !important; }"),n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.id=ye,o.type="text/css",o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t)),n.appendChild(o)}}(this.overlay_opacity),e)var n=setTimeout(function(){t.closeOverlayer(),clearTimeout(n)},e)},t.prototype.closeOverlayer=function(){var e;(e=document.getElementById(ye))&&e.parentElement.removeChild(e)},t.prototype.fetchComplete=function(e,t){var n=this;if(e&&"[object Object]"==Object.prototype.toString.call(e)){this.data=e,this.setAbCache(t);var o=[];Object.keys(e).forEach(function(t){var n=e[t].vid;n&&o.push(n)}),this.versions=this.versions.filter(function(e){return o.includes(e)});var i=e.$ab_url,r=e.$ab_modification;if(r&&r.val&&this.enable_ab_visual){if(this.collect.destroyInstance)return;this.getVar("$ab_modification",window.location.href,function(){var e;e=r.val,window.TEAVisualEditor=window.TEAVisualEditor||{},window.TEAVisualEditor.__ab_config=e,v("".concat("https://lf3-data.volccdn.com/obj/data-static/log-sdk/collect/visual-ab-loader.js","?query=").concat(Date.now()),function(){console.log("load visual render success")},function(){console.log("load visual render fail")}),n.closeOverlayer(),n.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 执行可视化实验",level:"info",logType:"fetch",time:Date.now(),infoType:"sdk",data:{$ab_modification:r}})})}else if(i&&this.enable_multilink){this.mulilinkVersions=this.mulilinkVersions.filter(function(e){return o.includes(e)}),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 执行多链接实验",level:"info",logType:"fetch",time:Date.now(),infoType:"sdk",data:{$ab_url:i}});var a=i.val,s=i.vid;a&&s&&this.getVar("$ab_url",a,function(){n.editMode||(a!==window.location.href?setTimeout(function(){if(!n.collect.destroyInstance){var e="".concat(a);e=-1===e.indexOf("http")?"https://".concat(e):e;var t=_(e).host;try{var o=new URL(e);t!==location.host?o.searchParams.append("vid",s):window.history.replaceState("","",e),window.location.href=o.href}catch(t){window.location.href=e}}},100):n.closeOverlayer())})}this.auto_exposure&&this.exposureAll(e),this.updateVersions()}else this.closeOverlayer();this.callbacks.forEach(function(e){return n[e.type===Ie.Var?"getRealVar":"getRealAllVars"](e,"")}),this.callbacks=[]},t.prototype.fetchAB=function(t){var n=this,o=this.collect.configManager.get(),i=o.header,r=o.user;this.config.enable_anonymousid&&delete r.web_id;var a=r.user_unique_id,s={header:e(e(e({aid:this.config.app_id},r||{}),i||{}),{ab_sdk_version:this.collect.configManager.getAbVersion(),ab_url:window.location.href})};this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 发起AB实验请求",level:"info",logType:"fetch",time:Date.now(),data:s,infoType:"sdk"});var c=this.collect.cryptoData(s);this.collect.requestManager.useRequest({url:this.fetchUrl,data:c,success:function(e){n.fetchStatus="complete",n.refreshFetchStatus="complete";var o=e.data;"success"===e.message?(n.fetchComplete(o,a),t&&t(o)):(n.fetchComplete(null,a),t&&t(null)),n.collect.emit(n.types.AbComplete,o),n.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求成功",level:"info",logType:"fetch",time:Date.now(),data:o,infoType:"sdk"})},fail:function(){n.fetchStatus="complete",n.refreshFetchStatus="complete",n.fetchComplete(null,a),t&&t(null),n.collect.emit(n.types.AbTimeout),n.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求网络异常",level:"error",logType:"fetch",time:Date.now(),infoType:"sdk"})},timeout:this.config.ab_timeout||1e4,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},t}();try{var Me=pe();Me&&(Me.LogAb=function(e,t){(new Re).apply(e,t)})}catch(e){console.log(e)}var xe=function(){function t(e,t){this.maxDuration=432e5,this.aliveDTime=6e4,this.options={aliveName:"predefine_page_alive",params:{}},this.collect=e,this.config=t,this.pageStartTime=Date.now(),this.sessionStartTime=this.pageStartTime,this.timerHandler=null,s(t.enable_stay_duration)&&(this.options=Object.assign(this.options,t.enable_stay_duration))}return t.prototype.setParams=function(e,t,n){this.set_path=e,this.set_url=n,this.set_title=t},t.prototype.resetParams=function(e,t,n){this.url_path=e,this.url=n,this.title=t},t.prototype.enable=function(e,t,n){this.url_path=e||this.url_path,this.url=n||this.url,this.title=t||this.title,this.disableCallback=this.enablePageAlive(),this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params},t.prototype.disable=function(){this.disableCallback(),this.pageStartTime=Date.now()},t.prototype.sendEvent=function(t,n){void 0===n&&(n=!1);var o=n?this.aliveDTime:Date.now()-this.sessionStartTime;o<0||o>this.aliveDTime||Date.now()-this.pageStartTime>this.maxDuration||(this.collect.beconEvent(this.options.aliveName,e({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),duration:o,is_support_visibility_change:m(),startTime:this.sessionStartTime,hidden:document.visibilityState,leave:t},this.customParmas)),this.sessionStartTime=Date.now(),this.resetParams(location.pathname,document.title,location.href))},t.prototype.getParams=function(e){switch(e){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},t.prototype.setUpTimer=function(){var e=this;return this.timerHandler&&clearInterval(this.timerHandler),setInterval(function(){Date.now()-e.sessionStartTime>e.aliveDTime&&e.sendEvent(!1,!0)},1e3)},t.prototype.visibilitychange=function(){"hidden"===document.visibilityState?this.timerHandler&&(clearInterval(this.timerHandler),this.sendEvent(!1)):"visible"===document.visibilityState&&(this.sessionStartTime=Date.now(),this.timerHandler=this.setUpTimer())},t.prototype.beforeunload=function(){document.hidden||this.sendEvent(!0)},t.prototype.enablePageAlive=function(){var e=this;this.timerHandler=this.setUpTimer();var t=this.visibilitychange.bind(this),n=this.beforeunload.bind(this);return f(document,"visibilitychange",t,!1),f(window,"pagehide",n,!1),function(){e.beforeunload(),p(document,"visibilitychange",t,!1),p(window,"beforeunload",n,!1),p(window,"pagehide",n,!1)}},t}(),Ce=function(){function t(e,t){var n=this;this.maxDuration=432e5,this.aliveDTime=6e4,this.options={closeName:"predefine_page_close",params:{}},this.visibilitychange=function(){"hidden"===document.visibilityState?n.activeEndTime=Date.now():"visible"===document.visibilityState&&(n.activeEndTime&&(n.totalTime+=n.activeEndTime-n.activeStartTime,n.activeTimes+=1),n.activeEndTime=void 0,n.activeStartTime=Date.now())},this.beforeunload=function(){if(n.totalTime+=(n.activeEndTime||Date.now())-n.activeStartTime,n.config.autotrack){try{window.sessionStorage.setItem("_tea_cache_duration",JSON.stringify({duration:n.totalTime,page_title:document.title||location.pathname}))}catch(e){}}n.sendEventPageClose()},this.collect=e,this.config=t,this.maxDuration=t.maxDuration||864e5,this.pageStartTime=Date.now(),s(t.enable_stay_duration)&&(this.options=Object.assign(this.options,t.enable_stay_duration)),this.resetData()}return t.prototype.setParams=function(e,t,n){this.set_path=e,this.set_url=n,this.set_title=t},t.prototype.resetParams=function(e,t,n){this.url_path=e,this.url=n,this.title=t},t.prototype.enable=function(e,t,n){this.url_path=e||this.url_path,this.url=n||this.url,this.title=t||this.title,this.disableCallback=this.enablePageClose()},t.prototype.disable=function(){this.disableCallback()},t.prototype.resetData=function(){this.activeStartTime=void 0===this.activeStartTime?this.pageStartTime:Date.now(),this.activeEndTime=void 0,this.activeTimes=1,this.totalTime=0,this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params,this.resetParams(location.pathname,document.title,location.href)},t.prototype.sendEventPageClose=function(){var t=Date.now()-this.pageStartTime;this.totalTime<0||t<0||this.totalTime>=this.maxDuration||(this.collect.beconEvent(this.options.closeName,e({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),active_times:this.activeTimes,duration:this.totalTime,total_duration:t,is_support_visibility_change:m()},this.customParmas)),this.pageStartTime=Date.now(),this.resetData())},t.prototype.getParams=function(e){switch(e){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},t.prototype.enablePageClose=function(){var e=this,t=this.visibilitychange.bind(this),n=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",n),function(){e.beforeunload(),document.removeEventListener("visibilitychange",t),window.removeEventListener("beforeunload",n),window.removeEventListener("pagehide",n)}},t}(),Ge=function(){function e(){}return e.prototype.apply=function(e,t){var n=this;if(this.collect=e,this.config=t,this.config.enable_stay_duration){this.title=document.title||location.pathname,this.url=location.href,this.url_path=location.pathname,this.pageAlive=new xe(e,t),this.pageClose=new Ce(e,t);var o=this.collect.Types;this.collect.on(o.ResetStay,function(e){var t=e.url_path,o=e.title,i=e.url;n.resetStayDuration(t,o,i)}),this.collect.on(o.RouteChange,function(e){e.init||t.disable_route_report||n.resetStayDuration()}),this.collect.on(o.SetStay,function(e){var t=e.url_path,o=e.title,i=e.url;n.setStayParmas(t,o,i)}),this.enable(this.url_path,this.title,this.url),this.ready(o.Stay),this.collect.emit(o.StayReady)}},e.prototype.ready=function(e){var t=this;if(this.collect.set(e),this.collect.hook._hooksCache.hasOwnProperty(e)){var n=this.collect.hook._hooksCache[e];if(!Object.keys(n).length)return;var o=function(e){n[e].length&&n[e].forEach(function(n){t.collect.hook.emit(e,n)})};for(var i in n)o(i)}},e.prototype.enable=function(e,t,n){this.pageAlive.enable(e,t,n),this.pageClose.enable(e,t,n)},e.prototype.disable=function(){this.pageAlive.disable(),this.pageClose.disable()},e.prototype.setStayParmas=function(e,t,n){void 0===e&&(e=""),void 0===t&&(t=""),void 0===n&&(n=""),this.pageAlive.setParams(e,t,n),this.pageClose.setParams(e,t,n),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayParams",level:"info",time:Date.now(),data:{url_path:e,title:t,url:n},infoType:"cus"})},e.prototype.reset=function(e,t,n){this.disable(),this.enable(e,t,n)},e.prototype.resetStayDuration=function(e,t,n){this.reset(e,t,n),this.collect.emit(U.DEBUGGER_MESSAGE,{type:U.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayDuration",level:"info",time:Date.now(),data:{url_path:e,title:t,url:n},infoType:"sdk"})},e}();try{var Be=pe();Be&&(Be.LogStay=function(e,t){(new Ge).apply(e,t)})}catch(e){console.log(e)}var Ne=function(){function e(){var e=this;this.setInterval=function(){e.clearIntervalFunc=y(function(){e.isSessionhasEvent&&e.endCurrentSession()},e.sessionInterval)},this.clearInterval=function(){e.clearIntervalFunc&&e.clearIntervalFunc()}}return e.prototype.apply=function(e,t){var n=this;if(this.collect=e,!t.disable_heartbeat){this.sessionInterval=6e4,this.startTime=0,this.lastTime=0,this.setInterval();var o=this.collect.Types;this.collect.on(o.SessionResetTime,function(){n.process()})}},e.prototype.endCurrentSession=function(){this.collect.event("_be_active",{start_time:this.startTime,end_time:this.lastTime,url:window.location.href,referrer:window.document.referrer,title:document.title||location.pathname}),this.isSessionhasEvent=!1,this.startTime=0},e.prototype.process=function(){this.isSessionhasEvent||(this.isSessionhasEvent=!0,this.startTime=+new Date);var e=this.lastTime||+new Date;this.lastTime=+new Date,this.lastTime-e>this.sessionInterval&&(this.clearInterval(),this.endCurrentSession(),this.setInterval())},e}(),Ue=function(){function e(){}return e.prototype.apply=function(e,t){var n=this;if(this.collect=e,this.config=t,!this.config.channel_domain&&!(this.config.disable_track_event||this.config.disable_sdk_monitor||this.config.enable_encryption)){var o=e.adapters.fetch;this.fetch=o,this.url=e.configManager.getUrl("event");var i=this.collect.Types;this.collect.on(i.Ready,function(){n.sdkOnload()}),this.collect.on(i.SubmitError,function(e){var t=e.type,o=e.eventData,i=e.errorCode;"f_data"===t&&n.sdkError(o,i)})}},e.prototype.sdkOnload=function(){var e=this;try{var t=this.collect.configManager.get(),n=t.header,o=t.user,i=n.app_id,r=n.app_name,a=n.sdk_version,s=o.web_id,c=o.anonymous_id,l={events:[{event:"onload",params:JSON.stringify({app_id:i,app_name:r||"",sdk_version:a,sdk_type:"script",sdk_config:this.config,sdk_desc:"TOB"}),local_time_ms:Date.now()}],user:{user_unique_id:this.config.enable_anonymousid?c:s},header:{}};setTimeout(function(){e.collect.requestManager.useRequest({url:e.url,data:[l],timeout:3e4,app_key:"566f58151b0ed37e",forceXhr:!0})},16)}catch(e){}},e.prototype.sdkError=function(e,t){var n=this;try{var o=e[0],i=o.user,r=o.header,a=[];e.forEach(function(e){e.events.forEach(function(e){a.push(e)})});var s={events:a.map(function(e){return{event:"on_error",params:JSON.stringify({error_code:t,app_id:r.app_id,app_name:r.app_name||"",error_event:e.event,sdk_version:r.sdk_version,local_time_ms:e.local_time_ms,tea_event_index:Date.now(),params:e.params,header:JSON.stringify(r),user:JSON.stringify(i)}),local_time_ms:Date.now()}}),user:{user_unique_id:i.user_unique_id},header:{}};setTimeout(function(){n.collect.requestManager.useRequest({url:n.url,data:[s],timeout:3e4,app_key:"566f58151b0ed37e",forceXhr:!0})},16)}catch(e){}},e}();function Le(e,t){if(void 0===t&&(t="list"),!e)return!1;if(t&&"list"===t){if(["LI","TR","DL"].includes(e.nodeName))return!0;if(e.dataset&&e.dataset.hasOwnProperty("teaIdx"))return!0;if(e.hasAttribute&&e.hasAttribute("data-tea-idx"))return!0}else{if(["A","BUTTON"].includes(e.nodeName))return!0;if(e.dataset&&e.dataset.hasOwnProperty("teaContainer"))return!0;if(e.hasAttribute&&e.hasAttribute("data-tea-container"))return!0;if(e.hasAttribute&&qe(e,"ss"))return!0}return!1}var Pe=function(e,t){return!!qe(e,t)};function ze(e){for(var t=e;t&&!Le(t,"container");){if("HTML"===t.nodeName||"BODY"===t.nodeName)return e;t=t.parentElement}return t||e}var je=function(e){if(!e)return"";var t="";return e.textContent?t=e.textContent.trim():e.innerText&&(t=e.innerText.trim()),"input"!==e.tagName&&"INPUT"!==e.tagName||(t=e.value||""),t};function Ve(e){for(var t=e;t&&t.parentNode;){if(t.hasAttribute("data-tea-ignore"))return!0;if("HTML"===t.nodeName||"body"===t.nodeName)return!1;t=t.parentNode}return!1}var Ke=function(e,t){return e.hasAttribute?e.hasAttribute(t):e.attributes?!(!e.attributes[t]||!e.attributes[t].specified):void 0},qe=function(e,t){if("string"==typeof t)return Ke(e,t);if(c(t)){for(var n=!1,o=0;o0})}return!0},Fe=function(e){if("svg"===e.tagName.toLowerCase())return!0;for(var t=e.parentElement,n=!1;t;)"svg"===t.tagName.toLowerCase()?(t=null,n=!0):t=t.parentElement;return n};var We=function(){function t(t,n,o){var i=this;this.clickEvent=function(e){(function(e,t){if(1!==e.nodeType)return!1;if(!t.svg&&Fe(e))return!1;if(["HTML","BODY"].includes(e.tagName.toUpperCase()))return!1;var n=e;return!!("none"!==n.style.display&&(Le(n,"container")||t.track_attr&&Pe(n,t.track_attr)||Je(n)))})(e.target,i.options)&&i.eventHandel({eventType:"dom",eventName:"click"},e)},this.changeEvent=function(e){i.eventHandel({eventType:"dom",eventName:"change"},e)},this.submitEvent=function(e){i.eventHandel({eventType:"dom",eventName:"submit"},e)},this.getPageViewEvent=function(t,n){n&&"pushState"===n&&i.eventHandel({eventType:"dom",eventName:"beat"},e({beat_type:0},t)),i.eventHandel({eventType:"dom",eventName:"page_view"},t)},this.getPageLoadEvent=function(e){i.eventHandel({eventType:"dom",eventName:"page_statistics"},{lcp:e})},this.config=o.getConfig().eventConfig,this.collect=n,this.options=t,this.beatTime=t.beat,this.statistics=!1}return t.prototype.init=function(e){this.eventHandel=e;var t=this.config.mode;this.addListener(t)},t.prototype.addListener=function(e){var t=this;if("proxy-capturing"===e&&(this.config.click&&window.document.addEventListener("click",this.clickEvent,!0),this.config.change&&window.document.addEventListener("change",this.changeEvent,!0),this.config.submit&&window.document.addEventListener("submit",this.submitEvent,!0),this.config.pv&&this.collect.on("route-change",function(e){var n=e.config,o=e.name;t.getPageViewEvent(n,o)}),this.config.beat)){try{"complete"===document.readyState?this.beatEvent(this.beatTime):window.addEventListener("load",function(){t.beatEvent(t.beatTime)});var n=0,o=null;window.addEventListener("scroll",function(){clearTimeout(o),o=setTimeout(i,500),n=document.documentElement.scrollTop||document.body.scrollTop});var i=function(){(document.documentElement.scrollTop||document.body.scrollTop)==n&&t.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:1})}}catch(e){}try{var r=window.performance&&window.performance.getEntriesByType("paint");if(r&&r.length)new PerformanceObserver(function(e){var n=e.getEntries(),o=n[n.length-1],i=o.renderTime||o.loadTime;t.statistics||(t.getPageLoadEvent(i),t.statistics=!0)}).observe({entryTypes:["largest-contentful-paint"]}),setTimeout(function(){t.statistics||(t.getPageLoadEvent(r[0].startTime||0),t.statistics=!0)},2e3);else this.getPageLoadEvent(0)}catch(e){this.getPageLoadEvent(0)}}},t.prototype.removeListener=function(){window.document.removeEventListener("click",this.clickEvent,!0),window.document.removeEventListener("change",this.changeEvent,!0),window.document.removeEventListener("submit",this.submitEvent,!0)},t.prototype.beatEvent=function(e){var t=this;try{var n;this.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:3}),this.beatTime&&(n=setInterval(function(){t.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:2})},e)),g(function(){t.eventHandel({eventType:"dom",eventName:"beat",eventSend:"becon"},{beat_type:0}),t.beatTime&&clearInterval(n)})}catch(e){}},t}(),Xe={eventConfig:{mode:"proxy-capturing",submit:!1,click:!0,change:!1,pv:!0,beat:!0,hashTag:!1,impr:!1},scoutConfig:{mode:"xpath"}},$e=function(){function e(e,t){this.config=e,this.config.eventConfig=Object.assign(this.config.eventConfig,t)}return e.prototype.getConfig=function(){return this.config},e.prototype.setConfig=function(e){return this.config=e},e}();function Qe(e){for(var t=[];null!==e.parentElement;)t.push(e),e=e.parentElement;var n=[],o=[];return t.forEach(function(e){var t=function(e){if(null===e)return{str:"",index:0};var t=0,n=e.parentElement;if(n)for(var o=n.children,i=0;i=0?n-i:0,s=o-r>=0?o-r:0;return{touch_x:Math.floor(a),touch_y:Math.floor(s)}}(e,r),s=r.element_width,c=r.element_height,l=a.touch_x,u=a.touch_y,h=Qe(t),f=h.element_path,p=h.positions,d=function(e){var t=ze(e),n=[];return function e(t){var o=function(e){var t="";return 3===e.nodeType?t=e.textContent.trim():e.dataset&&e.dataset.hasOwnProperty("teaTitle")?t=e.getAttribute("data-tea-title"):e.hasAttribute("ata-tea-title")?t=e.getAttribute("data-tea-title"):e.hasAttribute("title")?t=e.getAttribute("title"):"INPUT"===e.nodeName&&["button","submit"].includes(e.getAttribute("type"))?t=e.getAttribute("value"):"IMG"===e.nodeName&&e.getAttribute("alt")&&(t=e.getAttribute("alt")),t.slice(0,200)}(t);if(o&&-1===n.indexOf(o)&&n.push(o),t.childNodes.length>0)for(var i=t.childNodes,r=0;r0?i:0)),t.page_start_ms=o.navigationStart}catch(e){console.log("page_statistics event error ".concat(JSON.stringify(e)))}return t},t.prototype.handleBeadtEvent=function(e){e.event=this.eventName.beat,e.page_key=window.location.href,e.is_html=1,e.page_title=document.title,e.page_manual_key=this.initConfig.autotrack.page_manual_key||"";try{e.page_viewport_width=window.innerWidth,e.page_viewport_height=window.innerHeight,e.page_total_width=document.documentElement.scrollWidth,e.page_total_height=document.documentElement.scrollHeight,e.scroll_width=document.documentElement.scrollLeft+window.innerWidth,e.scroll_height=document.documentElement.scrollTop+window.innerHeight,e.since_page_start_ms=Date.now()-window.performance.timing.navigationStart,e.page_start_ms=window.performance.timing.navigationStart}catch(e){console.log("beat event error ".concat(JSON.stringify(e)))}return e},t.prototype.handleExposureEvent=function(e,t){if(Ve(t.target))return null;var n=Ze(e.event||this.eventName.exposure,t,t.target||t,this.options,this.ignore);if(n.$exposure_type=e.exposureType,this.options.exposure.callback){var o=this.options.exposure.callback(n);return o||Object.keys(o).length?o:(console.warn("exposure callback must return data!"),n)}return n},t.prototype.handleScrollEvent=function(e,t){var n=Ze(e.event||this.eventName.scroll,t,t.target||t,this.options,this.ignore);if(n=Object.assign(n,e.params),!this.options.scroll.callback||(n=this.options.scroll.callback(n))||Object.keys(n).length)return n;console.warn("scroll callback must return data!")},t}(),tt=function(){function e(e){this.collect=e}return e.prototype.send=function(e,t){var n=t.event;delete t.event,e&&"becon"===e.eventSend?this.collect.beconEvent(n,t):this.collect.event(n,t)},e.prototype.get=function(e,t){var n=Object.assign({headers:{"content-type":"application/json"},method:"GET"},t);fetch(e,n)},e.prototype.post=function(e,t){var n=Object.assign({headers:{"content-type":"application/json"},method:"POST"},t);fetch(e,n)},e}(),nt="_TEA_VE_OPEN",ot="_TEA_VE_APIHOST",it="lang",rt="_VISUAL_EDITOR_V",at="_VISUAL_EDITOR_U";function st(){try{var e=window.TEAVisualEditor.lang=window.TEAVisualEditor.lang||O.get(it),t=window.TEAVisualEditor.__editor_ajax_domain=window.TEAVisualEditor.__editor_ajax_domain||O.get(ot),n=window.TEAVisualEditor.__editor_verison=window.TEAVisualEditor.__editor_verison||O.get(rt),o=window.TEAVisualEditor.__editor_url=window.TEAVisualEditor.__editor_url||O.get(at),i=+new Date,r=new Date(i+18e5);O.set(nt,"1",{expires:r}),O.set(ot,t,{expires:r}),O.set(at,o,{expires:r}),O.set(it,e,{expires:r}),O.set(rt,n||"",{expires:r})}catch(e){console.log("set cookie err")}}var ct=!1;function lt(e){var t=e.event,n=e.editorUrl,o=e.autoTrackInstance;ct||(ct=!0,v(n,function(){Se(t,"editorScriptloadSuccess"),o.destroy()},function(){t&&Se(t,"editorScriptloadError"),ct=!1}))}function ut(e,t){window.TEAVisualEditor=window.TEAVisualEditor||{};var n="",o="".concat(P,"?query=").concat(Date.now());window.TEAVisualEditor.appId=t.app_id;var i=t.channel_domain,r="";if(Ee(["*"]),i){var a,s="";try{var c=window.performance.getEntriesByType("resource");if(c&&c.length&&(c.forEach(function(e){"script"===e.initiatorType&&e.name&&-1!==e.name.indexOf("collect")&&(s=e.name)}),s||document.currentScript&&(s=document.currentScript.src),s&&(a=s.split("/"))&&a.length)){r="https:/";for(var l=2;l=t.timeLimit&&!o.exposured&&t.exposureEvent(e,i,n,o)})},{threshold:n})}catch(e){console.log("IntersectionObserver error,msg: ".concat(JSON.stringify(e)))}return e._observer_instance}return console.log("your browser cannot support IntersectionObserver, so cannot report exposure event, please update"),null},e.prototype.exposureAdd=function(e,t){var n="mutation"===t?e.target:e,o=n.observeId,i=ae();if(o||this.observeMap.has(o)){var r=this.observeMap.get(o);if(r&&n!==r.instance)this.unobserve(n),this.observeMap.delete(o),n.observeId=i,n.visible=!1,this.observeMap.set(i,{instance:n.cloneNode(!0),isIntersecting:!1}),this.observe(n);else{if(!0===n.visible)return;this.handleBoundingExposure(n)}}else n.observeId=i,n.visible=!1,this.observeMap.set(i,{instance:n.cloneNode(!0),isIntersecting:!1}),this.observe(n)},e.prototype.exposureRemove=function(e){this.observeMap.has(e.observeId)&&(this.observeMap.delete(e.observeId),this.unobserve(e),e.observeId="",e.visible=!1)},e.prototype.exposureEvent=function(e,t,n,o){if(t>=this.ratio){if("0"===e.target.style.opacity||"hidden"===e.target.style.visibility)return;if(!0===o.exposured)return;o.startWait&&clearTimeout(o.startWait);var i=e.target.getAttribute("data-exposure-event");this.eventHandle({eventType:"dom",eventName:"exposure",event:i,exposureType:this.getExposureType(e.target)},e),e.target.visible=!0,e.target.hasExposure=!0,o.startTime=Date.now(),o.exposured=!0}else o.startTime=Date.now(),o.exposured=!1;this.observeMap.set(n,o)},e.prototype.observe=function(e){this.instance&&this.instance.observe(e)},e.prototype.unobserve=function(e){this.instance&&this.instance.unobserve(e)},e.prototype.getExposureDomToExposure=function(){var e=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(t){e.handleBoundingExposure(t)})},e.prototype.visibilitychange=function(){var e=this,t=null;"visible"===document.visibilityState?this.timeLimit?t=setTimeout(function(){e.getExposureDomToExposure()},this.timeLimit):this.getExposureDomToExposure():(clearTimeout(t),this.customType=void 0)},e.prototype.handleBoundingExposure=function(e){if(this.getBoundingRatio(e)>=this.ratio){e.visible=!0;var t=e.getAttribute&&e.getAttribute("data-exposure-event");this.eventHandle({eventType:"dom",eventName:"exposure",event:t,exposureType:this.customType||ht.RESUME_FORM_BACK},e)}},e.prototype.getBoundingRatio=function(e){var t=e.getBoundingClientRect(),n=t.top,o=t.left,i=t.width,r=t.height,a=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight;return n>=0&&o>=0&&n<=s&&o<=a?(i>a?a:i)*(s-n)/(i*r):0},e.prototype.getExposureType=function(e){return e.visible?!1!==e.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=ht.RESUME_FORM_PAGE:this.exposureType=ht.LIFECYCLE_SHOW_NEW:(e.hasExposure,!1!==e.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=ht.RESUME_FORM_PAGE:this.exposureType=ht.EXPOSURE_ONCE),this.exposureType},e.prototype.addListen=function(){var e=this;this.collect.on("set-exposure-type",function(t){e.customType=t});var t=this.visibilitychange.bind(this);if(f(document,"visibilitychange",t,!1),window.addEventListener("hashchange",function(t){var n=e.hashMap.get(t.oldURL);n&&location.href===n.prev?(e.backStatus=!0,e.exposureType=ht.RESUME_FORM_PAGE):(e.backStatus=!1,e.hashMap.set(location.href,{current:t.newURL,prev:t.oldURL}))}),this.collect.bridgeReport){var n=window.history.pushState;history.pushState=function(t){for(var r=[],a=1;a=n.distance&&n.distance&&n.eventHandle({eventType:"dom",eventName:"scroll",event:f,params:{$direction:u,$offsetY:s,$offsetX:a}},t)):3!==u&&4!==u||h===l&&(a=l-i,Math.abs(a)>=n.distance&&n.distance&&n.eventHandle({eventType:"dom",eventName:"scroll",event:f,params:{$direction:u,$offsetY:s,$offsetX:a}},t)),o=c,i=l},100);var c=e.scrollTop,l=e.scrollLeft,u=pt.NOT_SCROLL;c>o?u=pt.SCROLL_DOWN:ci?u=pt.SCROLL_LEFT:l=this.limit[e]&&this.report(!1)}catch(e){console.log(e)}},e.prototype.addErrorCount=function(e,t,n,o){var i=this;try{if(e&&e.length){var r=e[0].events;r&&r.length&&("f_data"===t?(o&&o.hasOwnProperty("sc")?this.addCount("log",t,r.length-o.sc):this.addCount("log",t,r.length),this.errorCode[t]=n):r.forEach(function(e){var o="log";for(var r in Et)if(-1!==Et[r].indexOf(e.event)){o=r;break}i.addCount(o,t,1),i.errorCode[t]=n}))}}catch(e){}},e.prototype.report=function(e){if(this.tracerCache){var t=[];this.tracerCache.forEach(function(e){console.log(e),e.forEach(function(e){t.push(e)})}),t&&t.length&&this.sendTracer(t,e)}},e.prototype.sendTracer=function(e,t){try{var n=this.collect.eventManager.merge(e);t&&window.navigator.sendBeacon?window.navigator.sendBeacon(this.reportUrl,JSON.stringify(n)):this.fetch(this.reportUrl,n),this.tracerCache=null}catch(e){}},e.prototype.processTracer=function(e,t,n){var o={count:e,state:n,key:t,params_for_special:"applog_trace",aid:this.appid,platform:"web",_staging_flag:1,sdk_version:B};"f_net"!==n&&"f_data"!==n||(o.errorCode=this.errorCode[n]);var i=this.collect.processEvent("applog_trace",o);if(i&&i.event)return delete i.is_bav,i},e.prototype.listener=function(){var e=this;document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&e.leavePage()}),g(function(){e.leavePage()})},e.prototype.leavePage=function(){this.report(!0)},e}();try{var wt=pe();wt&&(wt.LogTracer=function(e,t){(new St).apply(e,t)})}catch(e){console.log(e)}var kt=function(){function e(){this.verifyReady=!1,this.cleanStatus=!1}return e.prototype.apply=function(e,t){var n=this;S()||(this.collector=e,this.config=t,this.eventStorage=[],this.collector.on("submit-verify-h5",function(e){e&&e.length&&n.eventStore(e[0])}),this.checkUrl(),this.heartbeat())},e.prototype.checkUrl=function(){var e=window.location.href,t=b(e);t._r_d_&&t._r_c_k_?(this.verifyReady=!0,this.domain=t._r_d_,this.key=t._r_c_k_,this.checkCache()):this.collector.off("submit-verify-h5")},e.prototype.checkCache=function(){this.eventStorage.length&&this.postVerify(this.eventStorage)},e.prototype.heartbeat=function(){var e=this;this.heart=setInterval(function(){var t={event:"simulator_test__",local_time_ms:Date.now()},n=e.collector.configManager.get(),o=n.header,i={events:[t],user:n.user,header:o};e.eventStore(i)},6e4)},e.prototype.eventStore=function(e){this.cleanStatus||(this.verifyReady?this.postVerify(e):this.eventStorage.push(e))},e.prototype.cleanVerify=function(){this.cleanStatus=!0,this.eventStorage=[],clearInterval(this.heart)},e.prototype.postVerify=function(e){var t=this;try{var n=JSON.parse(JSON.stringify(e));c(e)?n.forEach(function(e){t.fetchLog(e)}):this.fetchLog(n)}catch(e){console.log("web verify post error ~")}},e.prototype.fetchLog=function(e){this.collector.requestManager.useRequest({url:"".concat(this.domain,"/simulator/h5/log?connection_key=").concat(this.key),data:e,timeout:2e4})},e.prototype.leave=function(){var e=this;document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&e.cleanVerify()}),g(function(){e.cleanVerify()})},e}(),Tt=A(function(e,t){e.exports=function e(t,n,o){function i(a,s){if(!n[a]){if(!t[a]){var c=D;if(!s&&c)return c(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};t[a][0].call(u.exports,function(e){var n=t[a][1][e];return i(n||e)},u,u.exports,e,t,n,o)}return n[a].exports}for(var r=D,a=0;a=43)}}).catch(function(){return!1})}(e).then(function(e){return f=e})}function y(e){var t=p[e.name],n={};n.promise=new a(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then(function(){return n.promise}):t.dbReady=n.promise}function _(e){var t=p[e.name],n=t.deferredOperations.pop();if(n)return n.resolve(),n.promise}function b(e,t){var n=p[e.name],o=n.deferredOperations.pop();if(o)return o.reject(t),o.promise}function E(e,t){return new a(function(n,o){if(p[e.name]=p[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);y(e),e.db.close()}var r=[e.name];t&&r.push(e.version);var a=i.open.apply(i,r);t&&(a.onupgradeneeded=function(t){var n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(h)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),o(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},n(t),_(e)}})}function S(e){return E(e,!1)}function w(e){return E(e,!0)}function k(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),o=e.versione.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||n){if(n){var r=e.db.version+1;r>e.version&&(e.version=r)}return!0}return!1}function T(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),o=new Uint8Array(n),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return a.resolve().then(function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),w(e)}).then(function(){return function(e){y(e);for(var t=p[e.name],n=t.forages,o=0;o>4,u[c++]=(15&o)<<4|i>>2,u[c++]=(3&i)<<6|63&r;return l}function X(e){var t,n=new Uint8Array(e),o="";for(t=0;t>2],o+=R[(3&n[t])<<4|n[t+1]>>4],o+=R[(15&n[t+1])<<2|n[t+2]>>6],o+=R[63&n[t+2]];return n.length%3==2?o=o.substring(0,o.length-1)+"=":n.length%3==1&&(o=o.substring(0,o.length-2)+"=="),o}var $={serialize:function(e,t){var n="";if(e&&(n=F.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===F.call(e.buffer))){var o,i=C;e instanceof ArrayBuffer?(o=e,i+=B):(o=e.buffer,"[object Int8Array]"===n?i+=U:"[object Uint8Array]"===n?i+=L:"[object Uint8ClampedArray]"===n?i+=P:"[object Int16Array]"===n?i+=z:"[object Uint16Array]"===n?i+=V:"[object Int32Array]"===n?i+=j:"[object Uint32Array]"===n?i+=K:"[object Float32Array]"===n?i+=q:"[object Float64Array]"===n?i+=H:t(new Error("Failed to get type for BinaryArray"))),t(i+X(o))}else if("[object Blob]"===n){var r=new FileReader;r.onload=function(){var n=M+e.type+"~"+X(this.result);t(C+N+n)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,G)!==C)return JSON.parse(e);var t,n=e.substring(J),o=e.substring(G,J);if(o===N&&x.test(n)){var i=n.match(x);t=i[1],n=n.substring(i[0].length)}var a=W(n);switch(o){case B:return a;case N:return r([a],{type:t});case U:return new Int8Array(a);case L:return new Uint8Array(a);case P:return new Uint8ClampedArray(a);case z:return new Int16Array(a);case V:return new Uint16Array(a);case j:return new Int32Array(a);case K:return new Uint32Array(a);case q:return new Float32Array(a);case H:return new Float64Array(a);default:throw new Error("Unkown type: "+o)}},stringToBuffer:W,bufferToString:X};function Q(e,t,n,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,o)}function Y(e,t,n,o,i,r){e.executeSql(n,o,i,function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(e,s){s.rows.length?r(e,a):Q(e,t,function(){e.executeSql(n,o,i,r)},r)},r):r(e,a)},r)}var Z={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var o in e)n[o]="string"!=typeof e[o]?e[o].toString():e[o];var i=new a(function(e,o){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return o(e)}n.db.transaction(function(i){Q(i,n,function(){t._dbInfo=n,e()},function(e,t){o(t)})},o)});return n.serializer=$,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,o=new a(function(t,o){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){Y(n,i,"SELECT * FROM "+i.storeName,[],function(n,o){for(var r=o.rows,a=r.length,s=0;s0)return void a(e.apply(r,[t,c,o,i-1]));s(n)}})})}).catch(s)});return s(c,o),c}.apply(this,[e,t,n,1])},removeItem:function(e,t){var n=this;e=l(e);var o=new a(function(t,o){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){Y(n,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){o(t)})})}).catch(o)});return s(o,t),o},clear:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var o=t._dbInfo;o.db.transaction(function(t){Y(t,o,"DELETE FROM "+o.storeName,[],function(){e()},function(e,t){n(t)})})}).catch(n)});return s(n,e),n},length:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var o=t._dbInfo;o.db.transaction(function(t){Y(t,o,"SELECT COUNT(key) as c FROM "+o.storeName,[],function(t,n){var o=n.rows.item(0).c;e(o)},function(e,t){n(t)})})}).catch(n)});return s(n,e),n},key:function(e,t){var n=this,o=new a(function(t,o){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){Y(n,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,n){var o=n.rows.length?n.rows.item(0).key:null;t(o)},function(e,t){o(t)})})}).catch(o)});return s(o,t),o},keys:function(e){var t=this,n=new a(function(e,n){t.ready().then(function(){var o=t._dbInfo;o.db.transaction(function(t){Y(t,o,"SELECT key FROM "+o.storeName,[],function(t,n){for(var o=[],i=0;i '__WebKitDatabaseInfoTable__'",[],function(n,o){for(var i=[],r=0;r0}var ne={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=$,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,o=n.ready().then(function(){for(var t=n._dbInfo,o=t.keyPrefix,i=o.length,r=localStorage.length,a=1,s=0;s=0;n--){var o=localStorage.key(n);0===o.indexOf(e)&&localStorage.removeItem(o)}});return s(n,e),n},length:function(e){var t=this.keys().then(function(e){return e.length});return s(t,e),t},key:function(e,t){var n=this,o=n.ready().then(function(){var t,o=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(o.keyPrefix.length)),t});return s(o,t),o},keys:function(e){var t=this,n=t.ready().then(function(){for(var e=t._dbInfo,n=localStorage.length,o=[],i=0;i=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}}):a.reject("Invalid arguments"),t),o}},oe=function(e,t){for(var n=e.length,o=0;o=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),a=r.next();!a.done&&(s=o(a.value,2),c=s[0],l=s[1],t.sizethis.maxTime&&(this.sleepTime=this.maxTime),this.storage.setItem(this.eventSleepTimeKey,this.sleepTime),clearTimeout(this.sleepFn),this.tryReportStoreData()},e.prototype.reduceDataFromDB=function(){return t(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),this.degradeStarted?(this.sendStatus=!1,this.goodCount+=1,clearTimeout(this.sleepFn),[4,this.storage.getItem(this.eventKey)]):[2];case 1:return e=t.sent(),this.tempId.length&&e&&(this.tempId.forEach(function(t){e.delete(t)}),this.tempId=[],this.setDataToDB(e)),this.storage.setItem(this.eventSleepTimeKey,this.sleepTime),[4,this.reportRest()];case 2:return t.sent(),[3,4];case 3:return t.sent(),console.warn("reduceDataFromDB error"),[3,4];case 4:return[2]}})})},e.prototype.reportRest=function(){return t(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.getItem(this.eventKey)];case 1:return(e=t.sent())&&e.size?(this.tryReportStoreData(),[3,3]):[2];case 2:return t.sent(),[3,3];case 3:return[2]}})})},e.prototype.random=function(){return Math.floor(1e4*Math.random())},e.prototype.fetchData=function(e){var t=this;this.collect.requestManager.useRequest({url:this.eventUrl,data:e,timeout:3e4,type:"event",status:"degrade",success:function(){t.reduceDataFromDB()}})},e.prototype.destroy=function(){this.collect.off("http-error"),this.collect.off("http-ok")},e}();try{var Ot=pe();Ot&&(Ot.LogStore=function(e,t){(new At).apply(e,t)})}catch(e){console.log(e)}var It=function(){function e(){this.autotrack=!1,this.spa=!1,this.cache={},this.allowHash=!1}return e.prototype.apply=function(e,t){if(t.spa||t.autotrack){var n=e.Types;this.collect=e,this.config=t,this.appid=t.app_id,this.allowHash=t.allow_hash,this.fncArray=new Map,this.setKey(),this.setLocation(),this.hack(),this.init(),this.listener(),e.emit(n.RouteReady)}},e.prototype.setKey=function(){var e=this.collect.adapters.storage;this.storage=new e(!1),this.cache_key="__tea_cache_refer_".concat(this.appid),this.cache={refer_key:"",refer_title:document.title||location.pathname,refer_manual_key:"",routeChange:!1},this.config.autotrack&&"object"==typeof this.config.autotrack&&this.config.autotrack.page_manual_key&&(this.cache.refer_manual_key=this.config.autotrack.page_manual_key),this.storage.setItem(this.cache_key,this.cache)},e.prototype.hack=function(){var e=this,t=window.history.pushState;history.pushState=function(n){for(var r=[],a=1;a-1){var n=e.split(".");t=n[0],e=n[1]}}catch(n){return{scope:t,cmd:e}}return{scope:t,cmd:e}},e}();me.usePlugin(Re,"ab"),me.usePlugin(Ge,"stay"),me.usePlugin(_t,"autotrack"),me.usePlugin(At,"degrade"),me.usePlugin(kt,"verify_h5"),me.usePlugin(Ne,"heartbeat"),me.usePlugin(Ue,"monitor"),me.usePlugin(It,"route"),me.usePlugin(St,"tracer"),function(e){if("undefined"!=typeof window){var t=function(){if("undefined"!=typeof window)return window.LogAnalyticsObject||window.TeaAnalyticsObject}();if(t&&window[t]){var n=window[t];n.sdkLoad?console.log("you page has load sdk file already, do not load another sdk file"):(e.task=n.q||[],window[t]=e.processCmd.bind(e),window[t].sdkLoad=!0,e.processTask())}}}(new Ct(me))}();